/**
 *  RefItem.java : IceBird project
 *  11:10:06 
 */
package icebird.compiler.ncomp.vs;

import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import icebird.compiler.ncomp.X86Assembler;
import icebird.compiler.ncomp.X86Register;
import icebird.compiler.ncomp.X86Register.GPR;
import icebird.metadata.BasicType;
import icebird.metadata.ReferenceType;

/**
 * @author Sergey Shulepoff[Knott]
 */
public final class RefItem extends WordItem {
	
	

	public RefItem(Location l) {
		super(l);
	}

	/* (non-Javadoc)
	 * @see icebird.compiler.ncomp.vs.WordItem#cloneConstant()
	 */
	protected WordItem cloneConstant() {
		if (!getLocation().isConstant()) 
			throw new IllegalStateException();
		
		return new RefItem(new NullConstantLocation());
	}

	/* (non-Javadoc)
	 * @see icebird.compiler.ncomp.vs.WordItem#loadConstant(icebird.compiler.ncomp.X86Register)
	 */
	protected void loadConstant(X86Register r) {
		X86Assembler asm = X86Assembler.getAsm();
		
		// Load null constant.
		asm.clear(r);
	}

	/* (non-Javadoc)
	 * @see icebird.compiler.ncomp.vs.WordItem#popFPU(icebird.compiler.ncomp.X86Register.GPR, int)
	 */
	protected void popFPU(GPR reg, int disp) {
		throw new NotImplementedException();
	}

	/* (non-Javadoc)
	 * @see icebird.compiler.ncomp.vs.WordItem#pushConstant()
	 */
	protected void pushConstant() {
		X86Assembler asm = X86Assembler.getAsm();
		
		// Load null constant.
		asm.push(0);
	}

	/* (non-Javadoc)
	 * @see icebird.compiler.ncomp.vs.WordItem#pushFPU(icebird.compiler.ncomp.X86Register.GPR, int)
	 */
	protected void pushFPU(GPR reg, int disp) {
		throw new NotImplementedException();
	}

	/* (non-Javadoc)
	 * @see icebird.compiler.ncomp.vs.Item#getType()
	 */
	@Override
	public BasicType getType() {
		return new ReferenceType(null);
	}

}
